package com.ourteam.education.api;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ourteam.education.dao.CourseItemDAOQueryBean;
import com.ourteam.education.dao.CourseTypeDAOQueryBean;
import com.ourteam.education.domain.CourseTypeBean;
import com.ourteam.frame.web.AbstractSearchModel;


public class CourseItemSearchBean extends AbstractSearchModel<CourseItemDAOQueryBean> {
	
	private String courseTypeName;
	
	private String[] status;
	

	public String getCourseTypeName() {
		return courseTypeName;
	}

	public void setCourseTypeName(String courseTypeName) {
		this.courseTypeName = courseTypeName;
	}
	
	public String[] getStatus() {
		return status;
	}

	public void setStatus(String[] status) {
		this.status = status;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return CourseTypeBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(CourseItemDAOQueryBean queryBean) throws Exception {
		
		CourseItemDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		
		if(StringUtils.isNoneBlank(courseTypeName)) {
			criteria.andCourseItemNameLike(courseTypeName);
		}
		
		if(ArrayUtils.isNotEmpty(status)) {
			criteria.andStatusIn(status);
		}

	}

}
